home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_gimp.idb / usr / freeware / share / gimp / scripts / camo.scm.z / camo.scm
Encoding:
GIMP Script-Fu Script  |  1999-07-21  |  3.5 KB  |  102 lines

  1. ;
  2. ;
  3. ;
  4. ; Chris Gutteridge (cjg@ecs.soton.ac.uk)
  5. ; At ECS Dept, University of Southampton, England.
  6.  
  7. ; This program is free software; you can redistribute it and/or modify
  8. ; it under the terms of the GNU General Public License as published by
  9. ; the Free Software Foundation; either version 2 of the License, or
  10. ; (at your option) any later version.
  11. ; This program is distributed in the hope that it will be useful,
  12. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ; GNU General Public License for more details.
  15. ; You should have received a copy of the GNU General Public License
  16. ; along with this program; if not, write to the Free Software
  17. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.  
  20. (define (script-fu-camo-pattern inSize inGrain inColor1 inColor2 inColor3 inSmooth inFlatten)
  21.  
  22.         (set! old-bg (car (gimp-palette-get-background)))
  23.         (set! theWidth inSize)
  24.     (set! theHeight inSize)
  25.         (set! theImage (car(gimp-image-new theWidth theHeight RGB)))
  26.  
  27.         (set! baseLayer (car (gimp-layer-new theImage theWidth theHeight RGBA_IMAGE "Background" 100 NORMAL)))
  28.         (gimp-image-add-layer theImage baseLayer 0)
  29.  
  30.         (set! thickLayer (car (gimp-layer-new theImage theWidth theHeight RGBA_IMAGE "Camo Thick Layer" 100 NORMAL)))
  31.         (gimp-image-add-layer theImage thickLayer 0)
  32.  
  33.         (set! thinLayer (car (gimp-layer-new theImage theWidth theHeight RGBA_IMAGE "Camo Thin Layer" 100 NORMAL)))
  34.         (gimp-image-add-layer theImage thinLayer 0)
  35.  
  36.         (gimp-selection-all theImage)
  37.         (gimp-palette-set-background inColor1)
  38.         (gimp-drawable-fill baseLayer BG-IMAGE-FILL)
  39.  
  40.         (plug-in-solid-noise TRUE theImage thickLayer 1 0 (rand 65536) 1 inGrain inGrain)
  41.         (plug-in-solid-noise TRUE theImage thinLayer 1 0 (rand 65536) 1 inGrain inGrain)
  42.         (gimp-threshold theImage thickLayer 127 255)
  43.         (gimp-threshold theImage thinLayer 145 255)
  44.  
  45.     (set! theBlur (- 16 inGrain))
  46.  
  47.         (gimp-palette-set-background inColor2)
  48.         (gimp-by-color-select theImage thickLayer '(0 0 0) 127 REPLACE  TRUE FALSE 0 FALSE)
  49.         (gimp-edit-clear theImage thickLayer)
  50.         (gimp-selection-invert theImage)
  51.         (gimp-edit-fill theImage thickLayer)
  52.         (gimp-selection-none theImage)
  53.         (if (= inSmooth TRUE) 
  54.         (script-fu-tile-blur theImage thickLayer theBlur TRUE TRUE FALSE)
  55.             ()
  56.         )
  57.  
  58.  
  59.         (gimp-palette-set-background inColor3)
  60.         (gimp-by-color-select theImage thinLayer '(0 0 0) 127 REPLACE  TRUE FALSE 0 FALSE)
  61.         (gimp-edit-clear theImage thinLayer)
  62.         (gimp-selection-invert theImage)
  63.         (gimp-edit-fill theImage thinLayer)
  64.         (gimp-selection-none theImage)
  65.         (if (= inSmooth TRUE) 
  66.         (script-fu-tile-blur theImage thinLayer (/ theBlur 2) TRUE TRUE FALSE)
  67.             ()
  68.         )
  69.  
  70.  
  71.         (if (= inFlatten TRUE) 
  72.             (gimp-image-flatten theImage)
  73.             ()
  74.         )
  75.         (gimp-palette-set-background old-bg)
  76.         (gimp-display-new theImage)
  77. )
  78.  
  79.  
  80.  
  81. ; Register the function with the GIMP:
  82.  
  83. (script-fu-register
  84.  "script-fu-camo-pattern"
  85.  "<Toolbox>/Xtns/Script-Fu/Patterns/Camouflage"
  86.  "foo"
  87.  "Chris Gutteridge: cjg@ecs.soton.ac.uk"
  88.  "28th April 1998"
  89.  "Chris Gutteridge / ECS @ University of Southampton, England"
  90.  ""
  91.  SF-VALUE "Image Size:" "256"
  92.  SF-VALUE "Granularity (0 - 15):" "7"
  93.  SF-COLOR "Color 1:"      '(33 100 58)
  94.  SF-COLOR "Color 2:"      '(170 170 60)
  95.  SF-COLOR "Color 3:"      '(150 115 100)
  96.  SF-TOGGLE "Smooth?" FALSE
  97.  SF-TOGGLE "Flatten?" TRUE
  98. )
  99.  
  100.